<!DOCTYPE html>
<head>
    <title>确认订单页面</title>
    @include('web.layout.head')
    @include('web.layout.header_proscenium')
    <link rel="stylesheet" href="{{mix('/css/web/order/submin_cart.css')}}">
</head>

<body>
    <div class="shopcar-header">
        <div class="w1200 f-cb">
            <a class="logo fl" href="<?php echo asset('');?>"><img src="{{asset('/img/web/logo/forget_logo.png')}}" alt=""></a>

            <div class="tit fl">配单页</div>
            <img class="flow1 fr" src="{{asset('/img/web/order/img1151.jpg')}}" alt="" class="fr">
        </div>
    </div>
    <form action="/member/buyer/items/order/store" method="post" accept-charset="utf-8"  id="form-post" name="form-post">
        {{csrf_field()}}
        <input type="hidden" name="id" value="{{$shop['id']}}">
        <div class="submit-order-wrap">
            <div class="w1200">
                <div class="subtitle"> 填写并确认订单信息</div>
                <div class="fir-wrap w-f">
                    <h3>收货地址确认</h3>
                    <div class="address-list f-cb">
                        <ul>
                            @if($address)
                                @foreach($address as $item)
                                    <li data-id="{{$item['id']}}" class="{{$item['is_default'] ? 'hover' : ''}}">
                                        <div class="cont">
                                            <span class="tit f-cb pro">
                                                <span class=" tt"> {{$item['receiver']}}</span>
                                                <span class="word">
                                                {{$item['address']}}        {{$item['phone']}}
                                                </span>
                                            </span>
                                        </div>
                                        <span class="seled"></span>
                                    </li>
                                    <?php
                                        if($item['is_default']){
                                            $address_id = $item['id'];
                                        }
                                    ?>
                                @endforeach
                            @endif
                        </ul>
                        <input type="hidden" name="address_id" value="{{isset($address_id) ? $address_id : ''}}">
                    </div>
                    <div class="addr-mana f-cb">
                        <a target="_blank" href="{{asset('/member/address')}}" class="new-addr-use fl">管理收货地址</a>
                    </div>
                </div>
                <div class="sec-wrap">
                    <h3>确认订单信息</h3>
                    <div class="pro-tab">
                        <table class="type-tit" width="100%">
                            <tr style="background: #eee;">
                                <th width="6%"></th>
                                <th width="26%" class="tex-ct">商品信息</th>
                                <th width="11%" class="tex-ct">单价(元)</th>
                                <th width="9%" class="tex-ct">数量</th>
                                <th width="7%">小计(元)</th>
                            </tr>
                        </table>
                        <div class="js-shop-item">
                            @if($shop)
                                <div class="item item{{$shop['shop_id']}}" data-shopid="{{$shop['shop_id']}}">
                                    <div class="clear"></div>
                                    {{--<div class="shopnm"><span class="shopnamedt" data-id="122">{{$shop['items_information']['seller_company']}}</span></div>--}}
                                    @foreach($shop['items_products'] as $k=>$sku)
                                    <table class="proli-tab coupon_table_1" test="test" width="100%">
                                        <tbody>
                                            <tr class="pro-tr" data-id="1">
                                                <td width="6%" style="text-align: center">
                                                    {{$k+1}}
                                                </td>
                                                <td width="26%" valign="top" class="" style="text-align: center">
                                                    <div class="cont">
                                                        {{$sku['product_name']}}
                                                        <span class="font">{{empty($sku['model'])?'':'型号：'.$sku['model']}} {{empty($sku['brand'])?'':'| 品牌：'.$sku['brand']}}</span>
                                                    </div>
                                                </td>
                                                <td width="11%" class="tex-ct">
                                                    <span class="unit">{{$sku['price']}}</span>
                                                </td>
                                                <td width="9%" class="tex-ct">
                                                    <div class="numbox f-cb">
                                                         ×{{$sku['num']}}
                                                        <input type="hidden" class="shop-id num key_num" value="{{$sku['num']}}">
                                                    </div>
                                                </td>
                                                <td width="7%" class="tex-ct"><span class="sum-pri" shop-id="1">{{$sku['price'] * $sku['num']}}</span></td>
                                            </tr>
                                        </tbody>
                                    </table>

                                    @endforeach
                                    <div class="fpmange invoice_shop_content_{{$shop['shop_id']}}" >
                                        <input type="hidden" class="invoice_shop_{{$shop['shop_id']}}" name="invoices" value="{{$default_invoice ? $default_invoice['id'] : ''}}">
                                        <div class="tit">
                                            发票管理:
                                            <span class="invoice_type">
                                                @if($default_invoice)
                                                    @if($default_invoice['invoice_message'] == 1)
                                                        个人发票
                                                        <?php $default_invoice_type = 'personal_invoice';?>
                                                    @else
                                                        {{$default_invoice['invoice_type'] == 1 ? '普通发票' : '专用发票'}}
                                                        @if($default_invoice['invoice_type'] == 1)
                                                            <?php $default_invoice_type = 'company_regular_invoice';?>
                                                        @else
                                                            <?php $default_invoice_type = 'company_special_invoice';?>
                                                        @endif
                                                    @endif
                                                @else
                                                    不开发票
                                                    <?php $default_invoice_type = 'no_invoicing';?>
                                                @endif
                                            </span>
                                            <span class="edit" data-shop-id="{{$shop['shop_id']}}" table-key=1>修改</span>
                                        </div>
                                        <div class="taitou">{{$default_invoice ? $default_invoice['invoice_title'] : '不开发票'}}</div>
                                        <div class="gl"><a href="{{asset('/member/buyer/invoices')}}"  target="_blank"> 管理发票信息</a></div>
                                        <div class="wx">温馨提示：发票的开票金额仅限实际支付金额（不包含积分抵扣等优惠部分）。每月25日（含25日）之后的付款订单，将在下月开具发票</div>
                                    </div>
                                    <div class="f-cb w-f mt10">
                                        <span class= "cost_goods" hidden>此订单包含需要您承担运费的商品</span>
                                    </div>
                                    <div class="fl remark">
                                        <span class="fl bz">备注：</span>
                                        <input name='remark'  type="text" class="fl tex content" placeholder="补充填写其他信息，如有快递不到也请留言备注" />
                                    </div>
                                    <div class="clear"></div>
                                    <div  class="cost"><span class= "cost_goods freight_hint"></span></div>
                                </div>
                            @endif
                        </div>
                    </div>
                    <div class="clear"></div>
                    <div class="bot-oper f-cb w-f">
                        <a href="javascript:;"><input type="submit" class="fr sub-btn" product-type="1" value="去付款"></a>
                        <span class="fr oran f24">￥ <span class="all-sum" id="all-sum">{{$shop['order_money']}}</span></span>
                        <span class="fr"> 总计：</span>
                    </div>
                </div>
            </div>
        </div>
    </form>
    <div class="mask"></div>
    <div class="editinvoce">
        <div class="title">发票信息
            <img  class="close_img" src="{{asset('/img/web/order/img121.png')}}">
        </div>
        <div class="lx">
            <ul>
                <li invoice-message-type='2' class="xz first_invoice company_regular_invoice" data-target="company_regular_invoice">普通发票</li>
                <li invoice-message-type='3' data-target="company_special_invoice" class="company_special_invoice">增值发票</li>
                <li invoice-message-type='1' data-target="personal_invoice" class="personal_invoice">个人</li>
                <li invoice-message-type='0' data-target="no_invoicing" class="no_invoicing">不开发票</li>
            </ul>
        </div>
        <div class="invoice_select">

        </div>

        <div class="invoice_btn btn">确定</div>
    </div>
    <script type="text/javascript">
        var invoice_list = '/member/buyer/invoices?type=order_select';
        var current_shop_id = '';
        var current_type = '{{$default_invoice_type}}';
        $(function(){
            $(".edit").click(function(){
                current_shop_id = $(this).data('shop-id');
                $.ajax({
                    url: invoice_list,
                    type: 'get',
                    data:{current_type:current_type},
                    success:function(html){
                        $('.invoice_select').html(html);
                    }
                });
                $(".lx ul li").removeClass('xz');

                if(current_type=='no_invoicing'){
                    $(".no_invoicing").addClass('xz');
                }else{
                    var li = $(".lx ul ."+current_type)[0];
                    $(li).trigger('click');
                }

                if($('.invoice_select .personal_invoice').find('.invoice_data').length < 1){
                    $(".invoice_btn").hide();
                }else{
                    $(".invoice_btn").show();
                }
                setTimeout(function(){
                    $(".editinvoce").show();
                    $(".fpdt").show();
                },200);
             })
            $(".lx ul li").click(function(){
                // 选项卡选择不更改全局发票选择状态。确认按钮更改发票状态。
                _this_current_type = $(this).data('target');
                //选择发票类型
                if($('.' + _this_current_type).find('.invoice_data').length < 1){
                    $(".invoice_btn").hide();
                }else{
                    $(".invoice_btn").show();
                }
                $('.invoice_select .invoices_content_list').hide();
                $('.invoice_select .' + _this_current_type).show();
                //更换高亮
                $(".lx ul li").removeClass('xz');
                $(this).addClass('xz');
            })
            $(".invoice_btn").click(function(){
                // 当前发票类型应该根据 点击了确认之后的类型相同。
                choose = $('.lx ul .xz'); // 选择被选中的 li 即发票信息
                current_type = $(choose).data('target');

                var $invoice_data = $('.' + current_type).find('.invoice_data');
                var invoice_id = $invoice_data.data('invoice-id');
                var invoice_type = $invoice_data.data('type');
                var invoice_title = $invoice_data.data('title');
                $('.invoice_shop_'+current_shop_id).val(invoice_id);
                $('.invoice_shop_content_'+current_shop_id).find('.invoice_type').text(invoice_type);
                $('.invoice_shop_content_'+current_shop_id).find('.taitou').text(invoice_title);
                $(".editinvoce").hide();
            });
            $(".close_img").on('click',function(event) {
                event.preventDefault();
                /* Act on the event */
                $(".editinvoce").hide();
            });
            $(".invoice_manage").on('click',function(event) {
                event.preventDefault();
                /* Act on the event */
                location.href = '/member/inovce_list';
            });
        })
    </script>
    @include('web.layout.footer_ware1')
    <script>
        var new_data = {};
        new_data.information = 'person';
        var product_data = {};
        var library_data ={};
        var shop_data ={};
        new_data.coupons_data = {};
        new_data.invoice_data = {};
        var shops_data =[];
        $(function() {
            $('table .cancel,.add-address .close').click(function(event) {
                $('.add-address').hide();
                $('.mask').hide();
            });

        })
    </script>
    <script type="text/javascript">

        $(function() {
            // 发票
            $(".j-bill").click(function() {
                var $this = $(this), type = $this.data('type');
                $this.addClass("hover").siblings().removeClass("hover");
                $this.find(".i").show();
                $this.siblings().find(".i").hide();
                $('input[name="isbill"]').val(type);
                if ('1' == type) {
                    // 发票类型处理
                    var _bill_type = $(".j-bill-type:eq(0)");
                    _bill_type.addClass("hover").siblings().removeClass("hover");
                    _bill_type.find(".i").show();
                    _bill_type.siblings().find(".i").hide();
                    $('input[name="billtype"]').val('1');
                    $this.parents('.invoice-wrap').find('.zengzhi_invoice').show();
                    $this.parents('.invoice-wrap').find('.invoice_taitou').hide();
                    new_data.invoice_type = 1;
                    new_data.information = 'company';
                } else {
                    $this.parents('.invoice-wrap').find('.zengzhi_invoice').hide();
                    $this.parents('.invoice-wrap').find('.invoice_taitou').show();
                    new_data.information = 'person';
                }
            });
            $(".j-bill-type").click(function() {
                var $this = $(this), type = $this.data('type');
                $this.addClass("hover").siblings().removeClass("hover");
                $this.find(".i").show();
                $this.siblings().find(".i").hide();
                $('input[name="billtype"]').val(type);
                new_data.invoice_type = type;
            });
        })
    </script>
    <script type="text/javascript">
        $(function() {
            $("body").on('click', '.address-list ul li', function(event) {
                event.preventDefault();
                /* Act on the event */
                $(this).find(".seled").show();
                $(this).addClass("hover").siblings().removeClass("hover");
                address_id = $(this).attr('data-id');
                $('input[name="address_id"]').val(address_id);
                $(this).siblings().find(".seled").hide();
                _freight();
            });
        })
    </script>
    <script type="text/javascript">
        // 支付
        $(".sub-btn").on('click', function(event) {
            event.preventDefault();

            if(!$('input[name="address_id"]').val()){
                layer.alert('请选择收货地址',{icon: 2});
                return false;
            }
            $('form').submit();
        });

    </script>
</body>

</html>